--nButtons Skinns does ugly buttons, and removes.
-- Credits Neal, for hes awsome command.

local nButtons = CreateFrame('Frame', nil, UIParent)
nButtons:RegisterEvent('AddOn_LOADED')
nButtons:SetScript('OnEvent', function(self, event, AddOn)
    if AddOn == "nButtons" then 
        for i = 1, 12 do
            CreateBorder(_G["SpellBookCompanionButton"..i], 12, R, G, B)
        end

        for i = 1, 12 do
            CreateBorder(_G["SendMailAttachment"..i], 12, R, G, B, 2, 2, 1, 2, 2, 1, 1, 1)
        end
		
		CreateBorder(_G["OpenMailMoneyButton"], 12, R, G, B, 2, 2, 1, 2, 2, 1, 1, 1)

        for i = 1, 12 do 
            CreateBorder(_G["OpenMailAttachmentButton"..i], 12, R, G, B, 2, 2, 1, 2, 2, 1, 1, 1)
        end

        for i = 1, 7 do
            CreateBorder(_G["TradePlayerItem"..i.."ItemButton"], 12, R, G, B, 2)
        end

        for i = 1, 7 do
            CreateBorder(_G["TradeRecipientItem"..i.."ItemButton"], 12, R, G, B, 2)
        end

        for i = 1, 7 do
            CreateBorder(_G["MailItem"..i.."Button"], 12, R, G, B, 3, 3, 3, 3, 3, 2, 3, 2) 
        end

        for i = 1, 5 do
            CreateBorder(_G["SpellBookSkillLineTab"..i], 12, R, G, B, 3, 3, 3, 3, 3, 2, 3, 2) 
            select(3, _G["SpellBookSkillLineTab"..i]:GetRegions()):SetTexCoord(.08, .92, .08, .92)
            select(4, _G["SpellBookSkillLineTab"..i]:GetRegions()):SetTexCoord(.08, .92, .08, .92)
        end

        for i = 1, 5 do
           CreateBorder(_G["QuestProgressItem"..i], 12, R, G, B, 0, 0, -2, 0, 0, 0, -2, 0) 
        end

        for i = 1, 5 do
           CreateBorder(_G["QuestInfoItem"..i], 12, R, G, B, 0, 0, -2, 0, 0, 0, -2, 0) 
        end  

        for i = 1, 12 do 
            CreateBorder(_G["MerchantItem"..i.."ItemButton"], 12, R, G, B, 2)
        end
	
        for i = 1, 10 do
			_G["PetStableStabledPet"..i]:GetRegions():SetTexCoord(.08, .92, .08, .92)
	        CreateBorder(_G["PetStableStabledPet"..i], 12, R, G, B)
        end
		
		for i = 1, 12 do 
		    CreateBorder(_G["SpellButton"..i], 12, R, G, B, 3)
		end	

        for i  = 1, 3 do 
		    CreateBorder(_G["PaperDollSidebarTab"..i], 12, R, G, B)
		end
		
		for i = 1, 15 do
		    CreateBorder(_G["GearManagerDialogPopupButton"..i], 12, R, G, B, 2, 2, 2, 2, 2, 3, 2, 3)
		end
		
		CreateBorder(_G["StaticPopup1ItemFrame"], 12, R, G, B, 1) 
		--CreateBorder(_G["GearManagerToggleButton"], 12, R, G, B)
	
        CreateBorder(_G["MerchantRepairItemButton"], 12, R, G, B)
        CreateBorder(_G["MerchantRepairAllButton"], 12, R, G, B)
		CreateBorder(_G["MerchantGuildBankRepairButton"], 12, R, G, B)
	    CreateBorder(_G["MerchantBuyBackItemItemButton"], 12, R, G, B, 2)
	
        CreateBorder(_G["LFDQueueFrameRandomScrollFrameChildFrameItem1"], 12, R, G, B, 2, 2, 2, 2, 2, -1, 2, -1)

	    CreateBorder(_G["PrimaryProfession1SpellButtonBottom"], 12, R, G, B)	
        CreateBorder(_G["PrimaryProfession1SpellButtonTop"], 12, R, G, B)	
        CreateBorder(_G["PrimaryProfession2SpellButtonBottom"], 12, R, G, B)
        CreateBorder(_G["PrimaryProfession2SpellButtonTop"], 12, R, G, B)
	
        CreateBorder(_G["SecondaryProfession1SpellButtonRight"], 12, R, G, B)
        CreateBorder(_G["SecondaryProfession1SpellButtonLeft"], 12, R, G, B)
        CreateBorder(_G["SecondaryProfession2SpellButtonRight"], 12, R, G, B)
        CreateBorder(_G["SecondaryProfession3SpellButtonRight"], 12, R, G, B)
        CreateBorder(_G["SecondaryProfession3SpellButtonLeft"], 12, R, G, B)
        CreateBorder(_G["SecondaryProfession4SpellButtonRight"], 12, R, G, B)

        _G["CharacterModelFrameRotateRightButton"]:Hide()
        _G["CharacterModelFrameRotateLeftButton"]:Hide()
  
        _G["DressUpModelRotateRightButton"]:Hide()
        _G["DressUpModelRotateLeftButton"]:Hide()

		_G["PetStableModelRotateLeftButton"]:Hide()
		_G["PetStableModelRotateRightButton"]:Hide()
		
        local itemslots = {"Head", "Neck", "Shoulder", "Shirt", "Chest", "Waist", "Legs", "Feet", "Wrist", "Hands", "Finger0", "Finger1", "Trinket0", "Trinket1", "Back", "MainHand","SecondaryHand", "Ranged", "Tabard",}

        for i = 1, getn(itemslots) do
	        local Characterslotsframe = CreateFrame("Frame", nil, _G["Character"..itemslots[i].."Slot"])
            Characterslotsframe:SetPoint("TOPLEFT", -1, 1)
	        Characterslotsframe:SetPoint("BOTTOMRIGHT", 1, -1)
	        Characterslotsframe:SetBackdropColor(0, 0, 0, 0)
	        CreateBorder(Characterslotsframe, 12, R, G, B)
        end
	elseif AddOn == "Blizzard_Calendar" then
        for i = 1, 10 do
            CreateBorder(_G["CalendarClassButton"..i], 12, R, G, B , 3, 4, 3, 4, 3, 3, 3, 3)
        end
        CreateBorder(_G["CalendarClassTotalsButton"], 12, R, G, B, 2, 5, 2, 5, 2, 4, 2, 4)
    elseif AddOn == "Blizzard_TalentUI" then
	    for i = 1, 2 do
		    CreateBorder( _G["PlayerSpecTab"..i], 12, R, G, B, 2)
		    select(2,  _G["PlayerSpecTab"..i]:GetRegions()):SetTexCoord(.08, .92, .08, .92)
	    end
		
		for i = 1, 21 do
		    CreateBorder(_G["PlayerTalentFramePetPanelTalent"..i], 12, R, G, B, 4)
		end
		
		for i = 1, 22 do
		    CreateBorder(_G["PlayerTalentFramePanel1Talent"..i], 12, R, G, B, 4)
		end
		
	    for i = 1, 22 do
            CreateBorder(_G["PlayerTalentFramePanel2Talent"..i], 12, R, G, B, 4)
		end

        for i = 1, 22 do
		    CreateBorder(_G["PlayerTalentFramePanel3Talent"..i], 12, R, G, B, 4)
		end
		CreateBorder(_G["PlayerTalentFramePanel1HeaderIcon"], 12, R, G, B, 2, 2, 0, 2, 2, 0, 0, 0)
	    CreateBorder(_G["PlayerTalentFramePanel2HeaderIcon"], 12, R, G, B, 2, 2, 0, 2, 2, 0, 0, 0)
		CreateBorder(_G["PlayerTalentFramePanel3HeaderIcon"], 12, R, G, B, 2, 2, 0, 2, 2, 0, 0, 0)
	
		_G["PlayerTalentFramePetModelRotateRightButton"]:Hide()
        _G["PlayerTalentFramePetModelRotateLeftButton"]:Hide()
    elseif AddOn == "Blizzard_InspectUI" then 
        _G["InspectModelFrameRotateLeftButton"]:Hide()
        _G["InspectModelFrameRotateRightButton"]:Hide()
		
	    local inspectslots = {"Head", "Neck", "Shoulder", "Shirt", "Chest", "Waist", "Legs", "Feet", "Wrist","Hands", "Finger0", "Finger1", "Trinket0", "Trinket1", "Back", "MainHand", "SecondaryHand", "Ranged", "Tabard",}

	    for i = 1, getn(inspectslots) do
		    local inspectslotframe = CreateFrame("Frame", nil, _G["Inspect"..inspectslots[i].."Slot"])
		    inspectslotframe:SetPoint("TOPLEFT", -1, 1)
		    inspectslotframe:SetPoint("BOTTOMRIGHT", 1, -1)
		    inspectslotframe:SetBackdropColor(0, 0, 0, 0)
		    CreateBorder(inspectslotframe, 12, R, G, B)
	    end
		
		for i = 1, 22 do
		    CreateBorder(_G["InspectTalentFrameTalent"..i], 12, R, G, B, 4)
        end
    elseif AddOn == "Blizzard_GuildBankUI" then
        for i = 1, 7 do
		    CreateBorder(_G["GuildBankTab"..i.."Button"], 12, R, G, B)
        end

		for i = 1, 14 do	
		   	local gbframe = CreateFrame("Frame", nil, _G["GuildBankColumn1Button"..i])
		    gbframe:SetPoint("TOPLEFT", -1, 1)
		    gbframe:SetPoint("BOTTOMRIGHT", 1, -1)
		    CreateBorder(gbframe, 12, R, G, B, 1)
			
		   	local gbframe2 = CreateFrame("Frame", nil, _G["GuildBankColumn2Button"..i])
		    gbframe2:SetPoint("TOPLEFT", -1, 1)
		    gbframe2:SetPoint("BOTTOMRIGHT", 1, -1)
		    CreateBorder(gbframe2, 12, R, G, B, 1)
			
		    local gbframe3 = CreateFrame("Frame", nil, _G["GuildBankColumn3Button"..i])
		    gbframe3:SetPoint("TOPLEFT", -1, 1)
		    gbframe3:SetPoint("BOTTOMRIGHT", 1, -1)
		    CreateBorder(gbframe3, 12, R, G, B, 1)
			
		   	local gbframe4 = CreateFrame("Frame", nil, _G["GuildBankColumn4Button"..i])
		    gbframe4:SetPoint("TOPLEFT", -1, 1)
		    gbframe4:SetPoint("BOTTOMRIGHT", 1, -1)
		    CreateBorder(gbframe4, 12, R, G, B, 1)
			
		   	local gbframe5 = CreateFrame("Frame", nil, _G["GuildBankColumn5Button"..i])
		    gbframe5:SetPoint("TOPLEFT", -1, 1)
		    gbframe5:SetPoint("BOTTOMRIGHT", 1, -1)
		    CreateBorder(gbframe5, 12, R, G, B, 1)
			
		    local gbframe6 = CreateFrame("Frame", nil, _G["GuildBankColumn6Button"..i])
		    gbframe6:SetPoint("TOPLEFT", -1, 1)
		    gbframe6:SetPoint("BOTTOMRIGHT", 1, -1)
		    CreateBorder(gbframe6, 12, R, G, B, 1)
			
		   	local gbframe7 = CreateFrame("Frame", nil, _G["GuildBankColumn7Button"..i])
		    gbframe7:SetPoint("TOPLEFT", -1, 1)
		    gbframe7:SetPoint("BOTTOMRIGHT", 1, -1)
		    CreateBorder(gbframe7, 12, R, G, B, 1)
		end   
	elseif AddOn == "Blizzard_GuildUI" then	
	    --CreateBorder(_G["GuildNextPerkButton"], 12, R, G, B, 2, 2, 2, 2, 2, 2, 2, 2)
        --CreateBorder(_G["GuildLatestPerkButton"], 12, R, G, B, 2, 2, 2, 2, 2, 2, 2, 2)
		for i = 1, 7 do
		    CreateBorder(_G["GuildRewardsContainerButton"..i], 12, R, G, B, -1)
		end	
		for i = 1, 7 do
		    CreateBorder(_G["GuildPerksContainerButton"..i], 12, R, G, B, -1)
		end
	elseif AddOn == "Blizzard_MacroUI" then	
	    for i = 1, 36 do
		    CreateBorder(_G["MacroButton"..i], 12, R, G, B, 3, 1, 3, 1, 3, 3, 3, 3)
        end
		CreateBorder(_G["MacroFrameSelectedMacroButton"], 12, R, G, B, 2)
    elseif AddOn == "Blizzard_TradeSkillUI" then
	    for i = 1, 7 do
	        CreateBorder(_G["TradeSkillReagent"..i], 12, R, G, B, 3, 1, -7, 1, 3, -1, -7, -1)
	    end
		CreateBorder(_G["TradeSkillSkillIcon"], 12, R, G, B, 2)
	elseif AddOn == "Blizzard_AuctionUI" then
        for i = 1, 8 do
		   CreateBorder(_G["BrowseButton"..i.."Item"], 12, R, G, B, 2)
	    end
		
		for i = 1, 9 do
		    CreateBorder(_G["BidButton"..i.."Item"], 12, R, G, B, 2)
		end
		
		for i = 1, 9 do
		    CreateBorder(_G["AuctionsButton"..i.."Item"], 12, R, G, B, 2)
	    end
		CreateBorder(_G["AuctionsItemButton"], 12, R, G, B, 2)
		
		_G["AuctionDressUpModelRotateRightButton"]:Hide()
		_G["AuctionDressUpModelRotateLeftButton"]:Hide()
	elseif AddOn == "Blizzard_GlyphUI" then	
	    for i = 1, 9 do
	        CreateBorder(_G["GlyphFrameScrollFrameButton"..i], 12, R, G, B)
		end
    elseif AddOn == "Blizzard_TrainerUI" then	
		for i = 1, 8 do
		    CreateBorder(_G["ClassTrainerScrollFrameButton"..i], 12, R, G, B)
		end
		CreateBorder(_G["ClassTrainerFrameSkillStepButton"], 12, R, G, B, 1)
    elseif AddOn == "Clique" then 
        CreateBorder(_G["CliqueSpellTab"], 12, R, G, B, 2)
		_G["CliqueSpellTab"]:GetRegions():SetTexCoord(.08, .92, .08, .92)
	end	
end)		